import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/login'
// import Areachoice from '../views/areachoice'
import Layout from '../views/layout'
import Userinfo from '../views/usermall/userinfo'
// import Userformation from '../views/usermall/userformation'
import Contract from '../views/usermall/contract'
import Userphone from '../views/usercensus/userphone'
import Formsheet from '../views/usermall/formsheet'
import Uservacation from '../views/usercensus/uservacation'
import Birthnotice from '../views/birthnotice'
import Userchange from '../views/monthreport/userChangeT'
import Personturn from '../views/personchange'
import Homepage from '../views/homepage'
import Education from '../views/monthreport/education'
import Quitjob from '../views/monthreport/quitjob'
// import Userdetail from '../views/usermall/userdetail'

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login
  },
  // {
  //   path: '/areachoice',
  //   name: 'areachoice',
  //   component: Areachoice
  // },
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    redirect:"/homepage",
    children:[
      {
          path:'userinfo',
          component:Userinfo
      },
      // {
      //   path:'userformation',
      //   component:Userformation
      // },
      {
        path:'contract',
        component:Contract
      },
      {
        path:'userphone',
        component:Userphone
      },
      {
        path:'formsheet',
        component:Formsheet
      },
      {
        path:'uservacation',
        component:Uservacation
      },
      {
        path:'birthnotice',
        component:Birthnotice
      },
      {
        path:'userchange',
        component:Userchange
      },
      {
        path:'personturn',
        component:Personturn
      },
      {
        path:'homepage',
        component:Homepage
      },
      {
        path:'education',
        component:Education
      },
      {
        path:'quitjob',
        component:Quitjob
      }
    ]
  }
]


const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})
router.beforeEach((to, from, next) => {
  var Authorization = localStorage.getItem('sessionId')
  if(Authorization || to.fullPath=="/" ){
    next()
  }else{
    next()
      router.push({
        path:'/'
    })
  }
})

export default router
